package top.codedance.iotp.tools.serverTool.utils;

public class SystemUtil {

    /**
     * 获取执行程序当前目录
     * @return
     */
    public static String getRuntimeDirPath(Class<?> clazz) {
        String path = clazz.getProtectionDomain().getCodeSource().getLocation().getPath();
        if (System.getProperty("os.name").contains("dows")) {
            path = path.substring(1, path.length());
        }
        if (path.endsWith(".jar")) {
            return path.substring(0, path.lastIndexOf("/") + 1);
        }
        return path.replace("classes/", "");
    }
}
